package org.lv.learning.web;

import org.lv.learning.service.IAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 *
 */
@RestController
@RequestMapping("/account")
public class AccountController {

    @Autowired
    private IAccountService accountService;

    /**
     *  扣减账户余额
     * @param userId
     * @param money
     * @return
     */
    @PutMapping("/deduct/{userId}/{money}")
    public Integer deduct(@PathVariable("userId") Long userId,
                          @PathVariable("money")BigDecimal money) {

        return accountService.deduct(userId, money);

    }

}
